package com.ruoyi.car.service.impl;

import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.github.pagehelper.PageHelper;
import com.github.pagehelper.PageInfo;
import com.ruoyi.car.controller.admin.company.vo.CarCompanyReq;
import com.ruoyi.car.entity.CarCompany;
import com.ruoyi.car.service.CarCompanyService;
import com.ruoyi.car.mapper.CarCompanyMapper;
import com.ruoyi.common.utils.StringUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

/**
* @author 11452
* @description 针对表【car_company(客户公司信息)】的数据库操作Service实现
* @createDate 2023-06-06 11:24:14
*/
@Service
public class CarCompanyServiceImpl extends ServiceImpl<CarCompanyMapper, CarCompany>
    implements CarCompanyService{

    @Autowired
    private CarCompanyMapper  carCompanyMapper;

    @Override
    public PageInfo<CarCompany> search(CarCompanyReq req) {

        return PageHelper.startPage(req.getPage(),req.getSize())
                .doSelectPageInfo(()->{
                    // where   name like '%?%'
                    LambdaQueryWrapper<CarCompany> queryWrapper=new LambdaQueryWrapper<>();
                    if(StringUtils.isNotBlank(req.getName())){
                        queryWrapper.like(CarCompany::getName, req.getName());
                    }

                    //状态
                    if(StringUtils.isNotBlank(req.getStatus())){
                        queryWrapper.eq(CarCompany::getStatus, req.getStatus());
                    }

                    carCompanyMapper.selectList(queryWrapper);
                });
    }
}




